{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "103e3fca",
   "metadata": {},
   "source": [
    "# Web服务API简介\n",
    "* 高德Web服务API向开发者提供HTTP接口，开发者可通过这些接口使用各类型的地理数据服务，返回结果支持JSON和XML格式。Web服务API对所有用户开放。使用本组服务之前，需要申请应用Key。不同类型用户可获取不同的数据访问能力。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "649d63e4",
   "metadata": {},
   "source": [
    "# 测试API功能"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1a8716a7",
   "metadata": {},
   "source": [
    "## 地理编码\n",
    "\n",
    "* 结构化地址：\n",
    "> 首先，地址肯定是一串字符，内含国家、省份、城市、区县、城镇、乡村、街道、门牌号码、屋邨、大厦等建筑物名称。按照由大区域名称到小区域名称组合在一起的字符。一个有效的地址应该是独一无二的。注意：针对大陆、港、澳地区的地理编码转换时可以将国家信息选择性的忽略，但省、市、城镇等级别的地址构成是不能忽略的。暂时不支持返回台湾省的详细地址信息。\n",
    "* 结构化地址---经纬度\n",
    "> 地理编码/逆地理编码 API 是通过 HTTP/HTTPS 协议访问远程服务的接口，提供结构化地址与经纬度之间的相互转化的能力"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "c4249e22",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2022-04-19T12:34:06.517299Z",
     "start_time": "2022-04-19T12:34:06.317325Z"
    }
   },
   "outputs": [],
   "source": [
    "# 1. 调用requests模块(比喻成：打开goole chrome浏览器才能搜索)\n",
    "import requests"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "1b6ebebd",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2022-04-19T12:34:46.399920Z",
     "start_time": "2022-04-19T12:34:46.274767Z"
    }
   },
   "outputs": [],
   "source": [
    "# 2. 请求的地址 url：https://restapi.amap.com/v3/geocode/geo?parameters\n",
    "geo_url = \"https://restapi.amap.com/v3/geocode/geo?parameters\"\n",
    "\n",
    "# 3. 请求方式：GET\n",
    "\n",
    "# 4. 请求参数\n",
    "payload = {\n",
    "    \"key\":\"682fce538eb09c02fe00d9268bf7f974\",\n",
    "    \"address\":\"广州市从化区中山大学南方学院\"\n",
    "}\n",
    "# 5. 发起请求\n",
    "r = requests.get(url = geo_url,params = payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "47119587",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2022-04-19T12:34:46.741884Z",
     "start_time": "2022-04-19T12:34:46.733905Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "c8d21bf1",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2022-04-19T12:38:43.617209Z",
     "start_time": "2022-04-19T12:38:43.607646Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'113.679287,23.632575'"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()['geocodes'][0]['location']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "09449dae",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2022-04-19T12:39:21.920379Z",
     "start_time": "2022-04-19T12:39:21.900466Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'113.679287,23.632575'"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "广州南方学院_location = r.json()['geocodes'][0]['location']\n",
    "广州南方学院_location"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a6ab4d95",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2022-04-19T12:39:39.130913Z",
     "start_time": "2022-04-19T12:39:39.113757Z"
    }
   },
   "source": [
    "## 逆地理编码"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "385f6b35",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2022-04-19T12:46:35.641987Z",
     "start_time": "2022-04-19T12:46:35.538276Z"
    }
   },
   "outputs": [],
   "source": [
    "# 2. 请求的地址 url：https://restapi.amap.com/v3/geocode/geo?parameters\n",
    "regeo_url = \"https://restapi.amap.com/v3/geocode/regeo?parameters\"\n",
    "\n",
    "# 3. 请求方式：GET\n",
    "\n",
    "# 4. 请求参数\n",
    "payload = {\n",
    "    \"key\":\"682fce538eb09c02fe00d9268bf7f974\",\n",
    "    \"location\":广州南方学院_location,    #变量不用加“”，加“”表示字符串\n",
    "    \"extensions\":\"all\",\n",
    "    \"poitype\":\"true\"\n",
    "}\n",
    "# 5. 发起请求\n",
    "r = requests.get(url = regeo_url,params = payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "e549be00",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2022-04-19T12:46:36.341141Z",
     "start_time": "2022-04-19T12:46:36.325324Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "9e4bee1d",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2022-04-19T12:46:37.600662Z",
     "start_time": "2022-04-19T12:46:37.574734Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'status': '1',\n",
       " 'info': 'OK',\n",
       " 'infocode': '10000',\n",
       " 'regeocode': {'formatted_address': '广东省广州市从化区温泉镇广州南方学院',\n",
       "  'addressComponent': {'country': '中国',\n",
       "   'province': '广东省',\n",
       "   'city': '广州市',\n",
       "   'citycode': '020',\n",
       "   'district': '从化区',\n",
       "   'adcode': '440117',\n",
       "   'township': '温泉镇',\n",
       "   'towncode': '440117100000',\n",
       "   'neighborhood': {'name': [], 'type': []},\n",
       "   'building': {'name': [], 'type': []},\n",
       "   'streetNumber': {'street': '博学路',\n",
       "    'number': '882号',\n",
       "    'location': '113.679226,23.632528',\n",
       "    'direction': '西南',\n",
       "    'distance': '8.10295'},\n",
       "   'businessAreas': [[]]},\n",
       "  'pois': [{'id': 'B00140MR9A',\n",
       "    'name': '广州南方学院',\n",
       "    'type': '科教文化服务;学校;高等院校',\n",
       "    'tel': '020-87828988;020-61787331',\n",
       "    'direction': '西',\n",
       "    'distance': '3.06387',\n",
       "    'location': '113.679257,23.632577',\n",
       "    'address': '温泉大道882号',\n",
       "    'poiweight': '0.450402',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGDU99RM',\n",
       "    'name': '广州南方学院图书馆',\n",
       "    'type': '科教文化服务;图书馆;图书馆',\n",
       "    'tel': '020-61787368;020-61787371',\n",
       "    'direction': '西北',\n",
       "    'distance': '23.6163',\n",
       "    'location': '113.679177,23.632762',\n",
       "    'address': '温泉大道882号广州南方学院内',\n",
       "    'poiweight': '0.257947',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGD58NF8',\n",
       "    'name': '广州南方学院达人书院',\n",
       "    'type': '科教文化服务;科教文化场所;科教文化场所',\n",
       "    'tel': [],\n",
       "    'direction': '西南',\n",
       "    'distance': '32.2733',\n",
       "    'location': '113.679041,23.632392',\n",
       "    'address': '温泉大道882号广州南方学院新综合楼2层',\n",
       "    'poiweight': '0.191229',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGD58FR2',\n",
       "    'name': '广州南方学院教学楼9号',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '东北',\n",
       "    'distance': '69.1226',\n",
       "    'location': '113.679747,23.633032',\n",
       "    'address': '广州南方学院',\n",
       "    'poiweight': '0.221662',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGDU92JC',\n",
       "    'name': '广州南方学院4号实验楼',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '东',\n",
       "    'distance': '69.4077',\n",
       "    'location': '113.679963,23.632652',\n",
       "    'address': '博学路附近',\n",
       "    'poiweight': '0.221662',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGD599JM',\n",
       "    'name': '广州南方学院第11教学楼',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '东北',\n",
       "    'distance': '101.294',\n",
       "    'location': '113.680037,23.633173',\n",
       "    'address': '温泉大道882号广州南方学院',\n",
       "    'poiweight': '0.221662',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HG5Z9JNK',\n",
       "    'name': '广州南方学院教学楼7号',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '西北',\n",
       "    'distance': '109.298',\n",
       "    'location': '113.678600,23.633330',\n",
       "    'address': '博学路',\n",
       "    'poiweight': '0.221553',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGDU7T1K',\n",
       "    'name': '广州南方学院教学楼10号',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '东北',\n",
       "    'distance': '132.988',\n",
       "    'location': '113.680125,23.633492',\n",
       "    'address': '从莞深高速(广州南方学院)',\n",
       "    'poiweight': '0.191229',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGD592BJ',\n",
       "    'name': '广州南方学院综合楼',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '东南',\n",
       "    'distance': '142.466',\n",
       "    'location': '113.680117,23.631544',\n",
       "    'address': '温泉大道886号广州南方学院内',\n",
       "    'poiweight': '0.221662',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0H25SMRKP',\n",
       "    'name': '广州南方学院大礼堂',\n",
       "    'type': '科教文化服务;会展中心;会展中心',\n",
       "    'tel': [],\n",
       "    'direction': '东南',\n",
       "    'distance': '143.881',\n",
       "    'location': '113.680076,23.631502',\n",
       "    'address': '温泉大道882号',\n",
       "    'poiweight': '0.261624',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGDU6Z41',\n",
       "    'name': '广州南方学院教学楼6号',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '西北',\n",
       "    'distance': '153.818',\n",
       "    'location': '113.678424,23.633710',\n",
       "    'address': '温泉大道882',\n",
       "    'poiweight': '0.221662',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGD580NZ',\n",
       "    'name': '广州南方学院惟贤门',\n",
       "    'type': '科教文化服务;学校;高等院校',\n",
       "    'tel': [],\n",
       "    'direction': '西北',\n",
       "    'distance': '154.082',\n",
       "    'location': '113.678437,23.633721',\n",
       "    'address': '博学路7号附近',\n",
       "    'poiweight': '0.285712',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0FFKP81F4',\n",
       "    'name': '政商研究院教学楼9号',\n",
       "    'type': '科教文化服务;学校;高等院校',\n",
       "    'tel': [],\n",
       "    'direction': '东北',\n",
       "    'distance': '163.951',\n",
       "    'location': '113.679949,23.633919',\n",
       "    'address': '博学路附近',\n",
       "    'poiweight': '0.191742',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGDU8NLD',\n",
       "    'name': '广州南方学院1号实验楼',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '西南',\n",
       "    'distance': '172.86',\n",
       "    'location': '113.678215,23.631370',\n",
       "    'address': '博学路附近',\n",
       "    'poiweight': '0.221662',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGD57E3S',\n",
       "    'name': '广州南方学院政商研究院',\n",
       "    'type': '科教文化服务;科教文化场所;科教文化场所',\n",
       "    'tel': [],\n",
       "    'direction': '东北',\n",
       "    'distance': '195.914',\n",
       "    'location': '113.680427,23.633994',\n",
       "    'address': '温泉镇博学路广州南方学院9号教学楼',\n",
       "    'poiweight': '0.191229',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGDU76L1',\n",
       "    'name': '广州南方学院教学楼5号',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '西北',\n",
       "    'distance': '201.138',\n",
       "    'location': '113.678046,23.633982',\n",
       "    'address': '中山路与博学路交叉口东南150米',\n",
       "    'poiweight': '0.221662',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HG3SCZP8',\n",
       "    'name': '桃园三章（校内店）',\n",
       "    'type': '商务住宅;住宅区;住宅小区',\n",
       "    'tel': '18570627158',\n",
       "    'direction': '北',\n",
       "    'distance': '207.618',\n",
       "    'location': '113.679685,23.634406',\n",
       "    'address': '第五食堂1层8号教学楼对面',\n",
       "    'poiweight': '0.209855',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGDU76L2',\n",
       "    'name': '广州南方学院2号实验楼',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '西南',\n",
       "    'distance': '210.76',\n",
       "    'location': '113.678211,23.630956',\n",
       "    'address': '博学路',\n",
       "    'poiweight': '0.221662',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B00140TWHT',\n",
       "    'name': '教工住宅1号',\n",
       "    'type': '商务住宅;住宅区;住宅小区',\n",
       "    'tel': [],\n",
       "    'direction': '南',\n",
       "    'distance': '251.758',\n",
       "    'location': '113.678490,23.630432',\n",
       "    'address': '笃行路2',\n",
       "    'poiweight': '0.157653',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGD58UTT',\n",
       "    'name': '广州南方学院8号教学楼',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '东北',\n",
       "    'distance': '225.543',\n",
       "    'location': '113.680399,23.634329',\n",
       "    'address': '博学路',\n",
       "    'poiweight': '0.191229',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0FFL7C054',\n",
       "    'name': '广州U优森特酒店',\n",
       "    'type': '住宿服务;住宿服务相关;住宿服务相关',\n",
       "    'tel': '15813395296',\n",
       "    'direction': '西南',\n",
       "    'distance': '8.10295',\n",
       "    'location': '113.679226,23.632528',\n",
       "    'address': '温泉镇博学路882号(广州南方学院商业中心1层)',\n",
       "    'poiweight': '0.317505',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGDU92JD',\n",
       "    'name': '广州南方学院教学楼1号',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '西',\n",
       "    'distance': '241.753',\n",
       "    'location': '113.677077,23.631783',\n",
       "    'address': '博学路19号',\n",
       "    'poiweight': '0.221662',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGDU8UYP',\n",
       "    'name': '广州南方学院继续教育学院招生办',\n",
       "    'type': '科教文化服务;学校;高等院校',\n",
       "    'tel': [],\n",
       "    'direction': '北',\n",
       "    'distance': '254.238',\n",
       "    'location': '113.679075,23.634853',\n",
       "    'address': '中山路',\n",
       "    'poiweight': '0.191229',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0FFLBEOND',\n",
       "    'name': '聚贤楼10号',\n",
       "    'type': '商务住宅;住宅区;宿舍',\n",
       "    'tel': [],\n",
       "    'direction': '东南',\n",
       "    'distance': '263.444',\n",
       "    'location': '113.681253,23.631036',\n",
       "    'address': '从莞深高速(广州南方学院)',\n",
       "    'poiweight': '0.190963',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0FFKP81F0',\n",
       "    'name': '教学楼1号(文学与传媒学院)',\n",
       "    'type': '科教文化服务;科教文化场所;科教文化场所',\n",
       "    'tel': [],\n",
       "    'direction': '西',\n",
       "    'distance': '263.674',\n",
       "    'location': '113.676866,23.631736',\n",
       "    'address': '博学路19号附近',\n",
       "    'poiweight': '0.191742',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGD58UTU',\n",
       "    'name': '广州南方学院2号教学楼',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '西南',\n",
       "    'distance': '264.846',\n",
       "    'location': '113.677060,23.631346',\n",
       "    'address': '博学路',\n",
       "    'poiweight': '0.191229',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0FFKP838K',\n",
       "    'name': '教学楼3号(外国语学院)',\n",
       "    'type': '科教文化服务;学校;高等院校',\n",
       "    'tel': [],\n",
       "    'direction': '西南',\n",
       "    'distance': '275.62',\n",
       "    'location': '113.677247,23.630947',\n",
       "    'address': '博学路25',\n",
       "    'poiweight': '0.191742',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGD588HJ',\n",
       "    'name': '广州南方学院教学楼4号',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '西南',\n",
       "    'distance': '297.315',\n",
       "    'location': '113.677460,23.630490',\n",
       "    'address': '博学路',\n",
       "    'poiweight': '0.221662',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0GUJYPEG2',\n",
       "    'name': '怒烤烤串(从化店)',\n",
       "    'type': '餐饮服务;中餐厅;特色/地方风味餐厅',\n",
       "    'tel': [],\n",
       "    'direction': '西',\n",
       "    'distance': '219.859',\n",
       "    'location': '113.677160,23.632910',\n",
       "    'address': '温泉大道882号广州南方学院内博学路6号之3',\n",
       "    'poiweight': '0.216026',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGD576F1',\n",
       "    'name': '广州南方学院音乐系',\n",
       "    'type': '科教文化服务;学校;高等院校',\n",
       "    'tel': [],\n",
       "    'direction': '北',\n",
       "    'distance': '316.942',\n",
       "    'location': '113.678792,23.635389',\n",
       "    'address': '中山路',\n",
       "    'poiweight': '0.285712',\n",
       "    'businessarea': []}],\n",
       "  'roads': [{'id': '020F49F0050461206',\n",
       "    'name': '博学路',\n",
       "    'direction': '南',\n",
       "    'distance': '156.951',\n",
       "    'location': '113.68,23.634'},\n",
       "   {'id': '020F49F0050462451',\n",
       "    'name': '中山路',\n",
       "    'direction': '东南',\n",
       "    'distance': '343.951',\n",
       "    'location': '113.677,23.6347'},\n",
       "   {'id': '020F49F006047765',\n",
       "    'name': 'S29从莞深高速',\n",
       "    'direction': '南',\n",
       "    'distance': '807.947',\n",
       "    'location': '113.682,23.6394'}],\n",
       "  'roadinters': [{'direction': '东南',\n",
       "    'distance': '343.951',\n",
       "    'location': '113.676794,23.634661',\n",
       "    'first_id': '020F49F0050461206',\n",
       "    'first_name': '博学路',\n",
       "    'second_id': '020F49F0050462451',\n",
       "    'second_name': '中山路'}],\n",
       "  'aois': [{'id': 'B00140MR9A',\n",
       "    'name': '广州南方学院',\n",
       "    'adcode': '440117',\n",
       "    'location': '113.679257,23.632577',\n",
       "    'area': '528560.656426',\n",
       "    'distance': '0',\n",
       "    'type': '141201'}]}}"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "4f8645aa",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2022-04-19T12:48:11.494379Z",
     "start_time": "2022-04-19T12:48:10.208148Z"
    }
   },
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "11d9bae7",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2022-04-19T12:49:35.910683Z",
     "start_time": "2022-04-19T12:49:35.833308Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>...</th>\n",
       "      <th>20</th>\n",
       "      <th>21</th>\n",
       "      <th>22</th>\n",
       "      <th>23</th>\n",
       "      <th>24</th>\n",
       "      <th>25</th>\n",
       "      <th>26</th>\n",
       "      <th>27</th>\n",
       "      <th>28</th>\n",
       "      <th>29</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>id</th>\n",
       "      <td>B00140MR9A</td>\n",
       "      <td>B0HGDU99RM</td>\n",
       "      <td>B0HGD58NF8</td>\n",
       "      <td>B0HGD58FR2</td>\n",
       "      <td>B0HGDU92JC</td>\n",
       "      <td>B0HGD599JM</td>\n",
       "      <td>B0HG5Z9JNK</td>\n",
       "      <td>B0HGDU7T1K</td>\n",
       "      <td>B0HGD592BJ</td>\n",
       "      <td>B0H25SMRKP</td>\n",
       "      <td>...</td>\n",
       "      <td>B0FFL7C054</td>\n",
       "      <td>B0HGDU92JD</td>\n",
       "      <td>B0HGDU8UYP</td>\n",
       "      <td>B0FFLBEOND</td>\n",
       "      <td>B0FFKP81F0</td>\n",
       "      <td>B0HGD58UTU</td>\n",
       "      <td>B0FFKP838K</td>\n",
       "      <td>B0HGD588HJ</td>\n",
       "      <td>B0GUJYPEG2</td>\n",
       "      <td>B0HGD576F1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>name</th>\n",
       "      <td>广州南方学院</td>\n",
       "      <td>广州南方学院图书馆</td>\n",
       "      <td>广州南方学院达人书院</td>\n",
       "      <td>广州南方学院教学楼9号</td>\n",
       "      <td>广州南方学院4号实验楼</td>\n",
       "      <td>广州南方学院第11教学楼</td>\n",
       "      <td>广州南方学院教学楼7号</td>\n",
       "      <td>广州南方学院教学楼10号</td>\n",
       "      <td>广州南方学院综合楼</td>\n",
       "      <td>广州南方学院大礼堂</td>\n",
       "      <td>...</td>\n",
       "      <td>广州U优森特酒店</td>\n",
       "      <td>广州南方学院教学楼1号</td>\n",
       "      <td>广州南方学院继续教育学院招生办</td>\n",
       "      <td>聚贤楼10号</td>\n",
       "      <td>教学楼1号(文学与传媒学院)</td>\n",
       "      <td>广州南方学院2号教学楼</td>\n",
       "      <td>教学楼3号(外国语学院)</td>\n",
       "      <td>广州南方学院教学楼4号</td>\n",
       "      <td>怒烤烤串(从化店)</td>\n",
       "      <td>广州南方学院音乐系</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>type</th>\n",
       "      <td>科教文化服务;学校;高等院校</td>\n",
       "      <td>科教文化服务;图书馆;图书馆</td>\n",
       "      <td>科教文化服务;科教文化场所;科教文化场所</td>\n",
       "      <td>科教文化服务;学校;学校</td>\n",
       "      <td>科教文化服务;学校;学校</td>\n",
       "      <td>科教文化服务;学校;学校</td>\n",
       "      <td>科教文化服务;学校;学校</td>\n",
       "      <td>科教文化服务;学校;学校</td>\n",
       "      <td>科教文化服务;学校;学校</td>\n",
       "      <td>科教文化服务;会展中心;会展中心</td>\n",
       "      <td>...</td>\n",
       "      <td>住宿服务;住宿服务相关;住宿服务相关</td>\n",
       "      <td>科教文化服务;学校;学校</td>\n",
       "      <td>科教文化服务;学校;高等院校</td>\n",
       "      <td>商务住宅;住宅区;宿舍</td>\n",
       "      <td>科教文化服务;科教文化场所;科教文化场所</td>\n",
       "      <td>科教文化服务;学校;学校</td>\n",
       "      <td>科教文化服务;学校;高等院校</td>\n",
       "      <td>科教文化服务;学校;学校</td>\n",
       "      <td>餐饮服务;中餐厅;特色/地方风味餐厅</td>\n",
       "      <td>科教文化服务;学校;高等院校</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>tel</th>\n",
       "      <td>020-87828988;020-61787331</td>\n",
       "      <td>020-61787368;020-61787371</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>...</td>\n",
       "      <td>15813395296</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>direction</th>\n",
       "      <td>西</td>\n",
       "      <td>西北</td>\n",
       "      <td>西南</td>\n",
       "      <td>东北</td>\n",
       "      <td>东</td>\n",
       "      <td>东北</td>\n",
       "      <td>西北</td>\n",
       "      <td>东北</td>\n",
       "      <td>东南</td>\n",
       "      <td>东南</td>\n",
       "      <td>...</td>\n",
       "      <td>西南</td>\n",
       "      <td>西</td>\n",
       "      <td>北</td>\n",
       "      <td>东南</td>\n",
       "      <td>西</td>\n",
       "      <td>西南</td>\n",
       "      <td>西南</td>\n",
       "      <td>西南</td>\n",
       "      <td>西</td>\n",
       "      <td>北</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>distance</th>\n",
       "      <td>3.06387</td>\n",
       "      <td>23.6163</td>\n",
       "      <td>32.2733</td>\n",
       "      <td>69.1226</td>\n",
       "      <td>69.4077</td>\n",
       "      <td>101.294</td>\n",
       "      <td>109.298</td>\n",
       "      <td>132.988</td>\n",
       "      <td>142.466</td>\n",
       "      <td>143.881</td>\n",
       "      <td>...</td>\n",
       "      <td>8.10295</td>\n",
       "      <td>241.753</td>\n",
       "      <td>254.238</td>\n",
       "      <td>263.444</td>\n",
       "      <td>263.674</td>\n",
       "      <td>264.846</td>\n",
       "      <td>275.62</td>\n",
       "      <td>297.315</td>\n",
       "      <td>219.859</td>\n",
       "      <td>316.942</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>location</th>\n",
       "      <td>113.679257,23.632577</td>\n",
       "      <td>113.679177,23.632762</td>\n",
       "      <td>113.679041,23.632392</td>\n",
       "      <td>113.679747,23.633032</td>\n",
       "      <td>113.679963,23.632652</td>\n",
       "      <td>113.680037,23.633173</td>\n",
       "      <td>113.678600,23.633330</td>\n",
       "      <td>113.680125,23.633492</td>\n",
       "      <td>113.680117,23.631544</td>\n",
       "      <td>113.680076,23.631502</td>\n",
       "      <td>...</td>\n",
       "      <td>113.679226,23.632528</td>\n",
       "      <td>113.677077,23.631783</td>\n",
       "      <td>113.679075,23.634853</td>\n",
       "      <td>113.681253,23.631036</td>\n",
       "      <td>113.676866,23.631736</td>\n",
       "      <td>113.677060,23.631346</td>\n",
       "      <td>113.677247,23.630947</td>\n",
       "      <td>113.677460,23.630490</td>\n",
       "      <td>113.677160,23.632910</td>\n",
       "      <td>113.678792,23.635389</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>address</th>\n",
       "      <td>温泉大道882号</td>\n",
       "      <td>温泉大道882号广州南方学院内</td>\n",
       "      <td>温泉大道882号广州南方学院新综合楼2层</td>\n",
       "      <td>广州南方学院</td>\n",
       "      <td>博学路附近</td>\n",
       "      <td>温泉大道882号广州南方学院</td>\n",
       "      <td>博学路</td>\n",
       "      <td>从莞深高速(广州南方学院)</td>\n",
       "      <td>温泉大道886号广州南方学院内</td>\n",
       "      <td>温泉大道882号</td>\n",
       "      <td>...</td>\n",
       "      <td>温泉镇博学路882号(广州南方学院商业中心1层)</td>\n",
       "      <td>博学路19号</td>\n",
       "      <td>中山路</td>\n",
       "      <td>从莞深高速(广州南方学院)</td>\n",
       "      <td>博学路19号附近</td>\n",
       "      <td>博学路</td>\n",
       "      <td>博学路25</td>\n",
       "      <td>博学路</td>\n",
       "      <td>温泉大道882号广州南方学院内博学路6号之3</td>\n",
       "      <td>中山路</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>poiweight</th>\n",
       "      <td>0.450402</td>\n",
       "      <td>0.257947</td>\n",
       "      <td>0.191229</td>\n",
       "      <td>0.221662</td>\n",
       "      <td>0.221662</td>\n",
       "      <td>0.221662</td>\n",
       "      <td>0.221553</td>\n",
       "      <td>0.191229</td>\n",
       "      <td>0.221662</td>\n",
       "      <td>0.261624</td>\n",
       "      <td>...</td>\n",
       "      <td>0.317505</td>\n",
       "      <td>0.221662</td>\n",
       "      <td>0.191229</td>\n",
       "      <td>0.190963</td>\n",
       "      <td>0.191742</td>\n",
       "      <td>0.191229</td>\n",
       "      <td>0.191742</td>\n",
       "      <td>0.221662</td>\n",
       "      <td>0.216026</td>\n",
       "      <td>0.285712</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>businessarea</th>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>...</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>10 rows × 30 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                     0                          1   \\\n",
       "id                           B00140MR9A                 B0HGDU99RM   \n",
       "name                             广州南方学院                  广州南方学院图书馆   \n",
       "type                     科教文化服务;学校;高等院校             科教文化服务;图书馆;图书馆   \n",
       "tel           020-87828988;020-61787331  020-61787368;020-61787371   \n",
       "direction                             西                         西北   \n",
       "distance                        3.06387                    23.6163   \n",
       "location           113.679257,23.632577       113.679177,23.632762   \n",
       "address                        温泉大道882号            温泉大道882号广州南方学院内   \n",
       "poiweight                      0.450402                   0.257947   \n",
       "businessarea                         []                         []   \n",
       "\n",
       "                                2                     3   \\\n",
       "id                      B0HGD58NF8            B0HGD58FR2   \n",
       "name                    广州南方学院达人书院           广州南方学院教学楼9号   \n",
       "type          科教文化服务;科教文化场所;科教文化场所          科教文化服务;学校;学校   \n",
       "tel                             []                    []   \n",
       "direction                       西南                    东北   \n",
       "distance                   32.2733               69.1226   \n",
       "location      113.679041,23.632392  113.679747,23.633032   \n",
       "address       温泉大道882号广州南方学院新综合楼2层                广州南方学院   \n",
       "poiweight                 0.191229              0.221662   \n",
       "businessarea                    []                    []   \n",
       "\n",
       "                                4                     5   \\\n",
       "id                      B0HGDU92JC            B0HGD599JM   \n",
       "name                   广州南方学院4号实验楼          广州南方学院第11教学楼   \n",
       "type                  科教文化服务;学校;学校          科教文化服务;学校;学校   \n",
       "tel                             []                    []   \n",
       "direction                        东                    东北   \n",
       "distance                   69.4077               101.294   \n",
       "location      113.679963,23.632652  113.680037,23.633173   \n",
       "address                      博学路附近        温泉大道882号广州南方学院   \n",
       "poiweight                 0.221662              0.221662   \n",
       "businessarea                    []                    []   \n",
       "\n",
       "                                6                     7   \\\n",
       "id                      B0HG5Z9JNK            B0HGDU7T1K   \n",
       "name                   广州南方学院教学楼7号          广州南方学院教学楼10号   \n",
       "type                  科教文化服务;学校;学校          科教文化服务;学校;学校   \n",
       "tel                             []                    []   \n",
       "direction                       西北                    东北   \n",
       "distance                   109.298               132.988   \n",
       "location      113.678600,23.633330  113.680125,23.633492   \n",
       "address                        博学路         从莞深高速(广州南方学院)   \n",
       "poiweight                 0.221553              0.191229   \n",
       "businessarea                    []                    []   \n",
       "\n",
       "                                8                     9   ...  \\\n",
       "id                      B0HGD592BJ            B0H25SMRKP  ...   \n",
       "name                     广州南方学院综合楼             广州南方学院大礼堂  ...   \n",
       "type                  科教文化服务;学校;学校      科教文化服务;会展中心;会展中心  ...   \n",
       "tel                             []                    []  ...   \n",
       "direction                       东南                    东南  ...   \n",
       "distance                   142.466               143.881  ...   \n",
       "location      113.680117,23.631544  113.680076,23.631502  ...   \n",
       "address            温泉大道886号广州南方学院内              温泉大道882号  ...   \n",
       "poiweight                 0.221662              0.261624  ...   \n",
       "businessarea                    []                    []  ...   \n",
       "\n",
       "                                    20                    21  \\\n",
       "id                          B0FFL7C054            B0HGDU92JD   \n",
       "name                          广州U优森特酒店           广州南方学院教学楼1号   \n",
       "type                住宿服务;住宿服务相关;住宿服务相关          科教文化服务;学校;学校   \n",
       "tel                        15813395296                    []   \n",
       "direction                           西南                     西   \n",
       "distance                       8.10295               241.753   \n",
       "location          113.679226,23.632528  113.677077,23.631783   \n",
       "address       温泉镇博学路882号(广州南方学院商业中心1层)                博学路19号   \n",
       "poiweight                     0.317505              0.221662   \n",
       "businessarea                        []                    []   \n",
       "\n",
       "                                22                    23  \\\n",
       "id                      B0HGDU8UYP            B0FFLBEOND   \n",
       "name               广州南方学院继续教育学院招生办                聚贤楼10号   \n",
       "type                科教文化服务;学校;高等院校           商务住宅;住宅区;宿舍   \n",
       "tel                             []                    []   \n",
       "direction                        北                    东南   \n",
       "distance                   254.238               263.444   \n",
       "location      113.679075,23.634853  113.681253,23.631036   \n",
       "address                        中山路         从莞深高速(广州南方学院)   \n",
       "poiweight                 0.191229              0.190963   \n",
       "businessarea                    []                    []   \n",
       "\n",
       "                                24                    25  \\\n",
       "id                      B0FFKP81F0            B0HGD58UTU   \n",
       "name                教学楼1号(文学与传媒学院)           广州南方学院2号教学楼   \n",
       "type          科教文化服务;科教文化场所;科教文化场所          科教文化服务;学校;学校   \n",
       "tel                             []                    []   \n",
       "direction                        西                    西南   \n",
       "distance                   263.674               264.846   \n",
       "location      113.676866,23.631736  113.677060,23.631346   \n",
       "address                   博学路19号附近                   博学路   \n",
       "poiweight                 0.191742              0.191229   \n",
       "businessarea                    []                    []   \n",
       "\n",
       "                                26                    27  \\\n",
       "id                      B0FFKP838K            B0HGD588HJ   \n",
       "name                  教学楼3号(外国语学院)           广州南方学院教学楼4号   \n",
       "type                科教文化服务;学校;高等院校          科教文化服务;学校;学校   \n",
       "tel                             []                    []   \n",
       "direction                       西南                    西南   \n",
       "distance                    275.62               297.315   \n",
       "location      113.677247,23.630947  113.677460,23.630490   \n",
       "address                      博学路25                   博学路   \n",
       "poiweight                 0.191742              0.221662   \n",
       "businessarea                    []                    []   \n",
       "\n",
       "                                  28                    29  \n",
       "id                        B0GUJYPEG2            B0HGD576F1  \n",
       "name                       怒烤烤串(从化店)             广州南方学院音乐系  \n",
       "type              餐饮服务;中餐厅;特色/地方风味餐厅        科教文化服务;学校;高等院校  \n",
       "tel                               []                    []  \n",
       "direction                          西                     北  \n",
       "distance                     219.859               316.942  \n",
       "location        113.677160,23.632910  113.678792,23.635389  \n",
       "address       温泉大道882号广州南方学院内博学路6号之3                   中山路  \n",
       "poiweight                   0.216026              0.285712  \n",
       "businessarea                      []                    []  \n",
       "\n",
       "[10 rows x 30 columns]"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.json_normalize(r.json()['regeocode']['pois']).T"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5a16d732",
   "metadata": {},
   "source": [
    "# 作业：\n",
    "* 1.尝试获取POI2.0接口\n",
    "* 2.获取中餐厅、西餐厅、快餐厅的信息（图片、内容等）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "868b2c48",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
